package cl.jpavlich.mpm.services;

import java.net.URI;
import java.net.URISyntaxException;

import cl.jpavlich.mpm.model.Copy;
import cl.jpavlich.mpm.model.Download;
import cl.jpavlich.mpm.model.ModPackage;
import cl.jpavlich.mpm.model.ModRepository;

public class PersistenceUtils {
	
	public static ModRepository createRepository() {
		ModRepository r = new ModRepository();
		
		for (int i=0; i<100; i++) {
			ModPackage p = createModPackage(i);
			
			r.addPackage(p);
			
		}
		return r;
	}

	/**
	 * @param i
	 * @return
	 */
	public static ModPackage createModPackage(int i) {
		ModPackage p = new ModPackage();
		p.setName("pkg"+  i);
		p.setAuthor("auth" + i);
//			p.setDate(new Date(i*10000000000l));
		p.setDescription("desc..." + i);
		p.setMinecraftversion(""+ Math.random() * 2);
		p.setModversion(""+ Math.random() * 5);
		try {
			p.setHomepage(new URI("http://www.minecraft.net"));
		} catch (URISyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		p.getInstallation().add(new Download("http://www.minecraft.net"));
		p.getInstallation().add(new Copy("aaa"+i, "bbb"+i, p));
		
		try {
			p.setDownloadURL(new URI("http://www.minecraft.net/index.html"));
		} catch (URISyntaxException e) {
			// do nothing
		}
		return p;
	}
}
